package com.jingsu;


import java.io.File;

public class ImageLoader {


    public static String getPath(String url) {
        if ( url==null || url.trim().length()==0 ) {
            return null;
        }

        if ( url.indexOf("360buyimg.com") > -1 ) {
            url = url.substring( url.indexOf("360buyimg.com") + 13);
        }

        if ( url.indexOf("grainger.cn") > -1 ) {
            url = url.substring( url.indexOf("grainger.cn") + 11);
        }

        if ( url.indexOf("suning.cn") > -1 ) {
            url = url.substring( url.indexOf("suning.cn") + 9);
        }

        if ( url.indexOf("mymro.cn") > -1 ) {
            url = url.substring( url.indexOf("mymro.cn") + 8);
        }

        if ( url!=null ) {
            url = url.replace('/', File.separatorChar).trim();
        }

        return url;
    }

    public static String getUnixPath(String url) {
        if ( url==null || url.trim().length()==0 ) {
            return null;
        }

        if ( url.indexOf("360buyimg.com") > -1 ) {
            url = url.substring( url.indexOf("360buyimg.com") + 13);
        }

        if ( url.indexOf("grainger.cn") > -1 ) {
            url = url.substring( url.indexOf("grainger.cn") + 11);
        }

        if ( url.indexOf("suning.cn") > -1 ) {
            url = url.substring( url.indexOf("suning.cn") + 9);
        }

        if ( url.indexOf("mymro.cn") > -1 ) {
            url = url.substring( url.indexOf("mymro.cn") + 8);
        }

        if ( url!=null ) {
            return url.trim();
        }

        return url;
    }

}
